<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>插入排序</title>
</head>
<body>
<script>
    function InsertSort(arr) {
        for (var i = 1; i < arr.length; i++) {
            var  key=arr[i] ;
            j = i - 1;
            while (j >= 0 && arr[j] > key) {
                arr[j + 1] = arr[j];
                j--;
            }
            arr[j+1] = key;
        }
        return arr;
    }
        var arr=[3,44,38,5,47,15,36,26,27,2,46,4,19,50,48];
        var a=InsertSort(arr);
        console.log(a);
</script>
</body>
</html>